package com.team.register.service;

import com.team.register.pojo.Admin;
import com.team.register.pojo.BaseUser;
import com.team.register.pojo.Customer;
import com.team.register.utils.FileUtil;
import com.team.register.utils.RoleUtil;

/**
 * @Description: 注册实现类
 * @author: Aron
 * @date: 2021.10.15
 */

public class SignUpServiceImpl implements SignUpService {
    /**
     * @Description: 注册方法
     * @Param: [strs]
     * @return: boolean
     * @Author: Aron
     * @Date: 2021/10/15
     */
    @Override
    public boolean signUp(String[] strs) {
        if (strs[0].equals(String.valueOf(RoleUtil.ADMIN))) {
            BaseUser admin = new Admin(strs[1], strs[2]);
            return FileUtil.write(admin);
        } else if (strs[0].equals(String.valueOf(RoleUtil.CUSTOMER))) {
            BaseUser customer = new Customer(strs[1], strs[2]);
            return FileUtil.write(customer);
        }
        return false;
    }
}
